﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ITAP.Core.Calculations;
using System.Drawing;
using ITAP.Core.Modelling;

namespace ITAP.ContourBuilder.Components.Dimensions
{
    [Serializable]
    public class RemoteRadiusDimension : ContourElementDimension
    {
        private int offsetFromHoleInPixels = 10;

        public int OffsetFromHoleInPixels
        {
            get { return offsetFromHoleInPixels; }
            set { offsetFromHoleInPixels = value; }
        }

        public override ModelPoint Position
        {
            get
            {
                float modelOffsetFromHole = coordinateConverter.ScreenMeasureToModelMeasure(offsetFromHoleInPixels, screenWidth, screenHeight, modelRectangle);
                ModelVector vector = this.Element.Primitive.GetNormalLine(0.5);
                ModelPoint centerPoint = this.Element.Primitive.GetPoint(0.5);
                vector.Length = modelOffsetFromHole;
                return ModelCalculations.GetOffsetPoint(centerPoint, vector);
            }
        }


        public override void Recalculate()
        {
        }

        public override bool IsPrimitiveDependsOnDisplayParameters
        {
            get
            {
                return true;
            }
        }

        public override ModelVector GetSizeLineNormal()
        {
            ModelVector vector = this.Element.Primitive.GetTangent(0.5);
            return vector.Rotate(new Angle(Math.PI));
        }

        public override void AcceptDimensionVisitor(IDimensionVisitor visitor)
        {
            visitor.Visit(this);
        }
    }
}
